<?php

namespace MoChat\App\Call\Model;

use Hyperf\Database\Model\Concerns\CamelCase;
use Hyperf\Database\Model\SoftDeletes;
use MoChat\Framework\Model\AbstractModel;

class CallPlanWorkContact extends AbstractModel
{
    use CamelCase;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'call_plan_work_contact';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'id' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime'
    ];

    public function getList($where, array $filed = ['*']): \Hyperf\Contract\LengthAwarePaginatorInterface
    {
        return self::where($where)->join('client as client', 'client.id', '=', 'call_plan_work_contact.client_id')->select($filed)->paginate();
    }

    public function getOmissionList($where, array $filed = ['*']): \Hyperf\Contract\LengthAwarePaginatorInterface
    {
        return self::where($where)
            ->join('client as client', 'client.id', '=', 'call_plan_work_contact.client_id')
            ->leftJoin('call_plan as plan', 'plan.id', '=', 'call_plan_work_contact.call_plan_id')
            ->select($filed)->paginate();
    }

}
